<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="/web/js/global/global_header.js"></script>
    <title>华锐Pms</title>
</head>

<body>
    <div id="app" class="bgc-f2 pl-16 pr-16 pt-16" v-cloak>
        <div>
            <div class="ub ub-ac ub-pe mb-16">
                <div>
                    <el-button type="primary" size="small" @click="editClick()" class="tx-14">添加酒店</el-button>
                </div>
            </div>
            <div class="bgc-wh ">
                <el-table :data="tableData" style="width: 100%" border
                    :header-cell-style="{background:'#eaedf4','color':'#333',padding:'8px 0'}">
                    <el-table-column prop="name" label="门店名称" width="180">
                    </el-table-column>
                    <el-table-column prop="address" label="门店地址" width="300">
                    </el-table-column>
                    <el-table-column prop="contacts" label="联系人" width="100">
                    </el-table-column>
                    <el-table-column prop="telephone" label="联系电话" width="150">
                    </el-table-column>
                    <el-table-column prop="crTime" label="创建时间">
                    </el-table-column>
                    <el-table-column fixed="right" label="操作" width="200">
                        <template slot-scope="scope">
                            <el-button @click="editClick(scope.row)" type="text" size="small" class="tx-14">编辑
                            </el-button>
                            <div class=" el-divider el-divider--vertical"></div>
                            <el-button type="text" size="small" class="tx-re tx-14" @click="delClick(scope.row)">删除
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <div class="pt-12 pb-12 pl-8 pr-8 ub ub-pe br" style="margin-top: -1px;">
                    <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
                        :current-page="params.pageNo" :page-sizes="[10, 20, 50, 100]" :page-size="params.pageSize"
                        layout="total, sizes, prev, pager, next, jumper" :total="total">
                    </el-pagination>
                </div>
            </div>
        </div>
    </div>
    <script type="text/babel">
        window.vm = new Vue({
            el: '#app',
            data: {
                tableData: [],
                total: 100,
                params: {
                    pageNo: 1,
                    pageSize: 10,
                },
            },
            mounted() {
            },
            beforeCreate() {
                top.vm.startLoading("加载中")
            },
            created() {
                this.getList();
            },
            methods: {
                getList() {
                    this.GET({ url: top.Config.curUrl + "/bst/bstHotel/list", map: this.params }).then((res) => {
                        if (res.retcode == 200) { //如果返回码不是200则提示错误登录信息
                            this.tableData = res.result.pageInfo.list;
                            this.total = res.result.pageInfo.total;
                        } else { //如果返回码是200则登录成功
                            this.msgError(res.retmsg)
                        }
                        top.vm.closeLoading();
                    })
                },
                //切换分页时触发
                handleCurrentChange(v) {
                    this.params.pageNo = v;
                    this.getList();
                },
                // 选择分页条数时触发
                handleSizeChange(v) {
                    this.params.pageSize = v;
                    this.getList();
                },
                // 编辑按钮
                editClick(row) {
                    this.openDetailsWin({
                        id: "hotel_manage_edit",
                        params: { id: row ? row.id : "" },
                        iframeUrl: "/web/view/hotel/hotel_manage_edit.html"
                    })
                },
                // 删除按钮
                delClick(row) {
                    this.confirm("您确认删除吗？").then(() => {
                        let params = JSON.parse(JSON.stringify(row))
                        params.status = -1
                        this.POST({ url: top.Config.curUrl + "/bst/bstHotel/save", map: params }).then((res) => {
                            if (res.retcode == 200) { //如果返回码不是200则提示错误登录信息
                                setTimeout(() => {
                                    this.getList();
                                    this.msgSuccess("删除成功");
                                }, 1000);
                            } else { //如果返回码是200则登录成功
                                this.msgError(res.retmsg);
                            }
                        })
                    })

                },
            }
        })

    </script>

</body>

</html>